//
//  FPBottomButtonView.m
//  ForestPack
//
//  Created by jimmy on 2018/7/10.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "FPBottomButtonView.h"
#import "FPCustomButton.h"
#import "Masonry.h"


@interface FPBottomButtonView()

//@property (nonatomic,strong)
//@property (nonatomic,strong)
//@property (nonatomic,strong)
//@property (nonatomic,strong)

@end

@implementation FPBottomButtonView

+(FPBottomButtonView *)initBottomButtonViewWithTitle:(NSString *)title
{
    FPBottomButtonView *view = [[FPBottomButtonView alloc] init];
    [view createUIWithTitle:title];
    return view;
}

- (void)createUIWithTitle:(NSString *)title {
    FPCustomButton * oneButton = [FPCustomButton buttonWithType:UIButtonTypeCustom];
    oneButton.layer.borderWidth = 0.5;
    oneButton.backgroundColor = [UIColor whiteColor];
    oneButton.layer.borderColor = RGB_COLOR(220,220,220).CGColor;
    [oneButton setTitle:@"关注店铺" forState:UIControlStateNormal];
    [oneButton setImage:[UIImage imageNamed:@"关注店铺"] forState:UIControlStateNormal];
    [oneButton setTitleColor:RGB_COLOR(153,153,153) forState:UIControlStateNormal];
    oneButton.titleLabel.font = [UIFont systemFontOfSize:10];
    oneButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [oneButton addTarget:self action:@selector(payAttentionClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:oneButton];
    [oneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 - 15));
        make.height.equalTo(self.mas_height);
    }];
    
    FPCustomButton * twoButton = [FPCustomButton buttonWithType:UIButtonTypeCustom];
    twoButton.layer.borderWidth = 0.5;
    twoButton.backgroundColor = [UIColor whiteColor];;
    twoButton.layer.borderColor = RGB_COLOR(220,220,220).CGColor;
    [twoButton setTitle:@"在线咨询" forState:UIControlStateNormal];
    [twoButton setImage:[UIImage imageNamed:@"在线咨询"] forState:UIControlStateNormal];
    [twoButton setTitleColor:RGB_COLOR(153,153,153) forState:UIControlStateNormal];
    twoButton.titleLabel.font = [UIFont systemFontOfSize:10];
    twoButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [twoButton addTarget:self action:@selector(onlineClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:twoButton];
    [twoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oneButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 - 15));
        make.height.equalTo(self.mas_height);
    }];
    
    self.fiveButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.fiveButton setTitle:@"立即购买" forState:UIControlStateNormal];
    self.fiveButton.backgroundColor = RGB_COLOR(237,34,59);
    [self.fiveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.fiveButton.titleLabel.font = [UIFont systemFontOfSize:14];
    self.fiveButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.fiveButton addTarget:self action:@selector(fiveClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.fiveButton];
    [self.fiveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(twoButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.5 + 30));
        make.height.equalTo(self.mas_height);
    }];
    
    self.threeButton = [FPCustomButton buttonWithType:UIButtonTypeCustom];
    [self.threeButton setTitle:@"电话咨询" forState:UIControlStateNormal];
    self.threeButton.backgroundColor = RGB_COLOR(255,149,0);
    [self.threeButton setImage:[UIImage imageNamed:@"电话咨询"] forState:UIControlStateNormal];
    [self.threeButton setTitleColor:RGB_COLOR(255,255,255) forState:UIControlStateNormal];
    self.threeButton.titleLabel.font = [UIFont systemFontOfSize:10];
    self.threeButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.threeButton addTarget:self action:@selector(phoneClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.threeButton];
    [self.threeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(twoButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 + 15));
        make.height.equalTo(self.mas_height);
    }];
    
    self.threeTextButton = [FPCustomButton buttonWithType:UIButtonTypeCustom];
    [self.threeTextButton setTitle:@"加入购物车" forState:UIControlStateNormal];
    self.threeTextButton.backgroundColor = RGB_COLOR(255,149,0);
    [self.threeTextButton setTitleColor:RGB_COLOR(255,255,255) forState:UIControlStateNormal];
    self.threeTextButton.titleLabel.font = [UIFont systemFontOfSize:10];
    self.threeTextButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.threeTextButton addTarget:self action:@selector(phoneClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.threeTextButton];
    [self.threeTextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(twoButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 + 15));
        make.height.equalTo(self.mas_height);
    }];

    self.sixButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.sixButton setTitle:@"加入购物车" forState:UIControlStateNormal];
    self.sixButton.backgroundColor = RGB_COLOR(255,149,0);
    [self.sixButton setTitleColor:RGB_COLOR(255,255,255) forState:UIControlStateNormal];
    self.sixButton.titleLabel.font = [UIFont systemFontOfSize:14];
    self.sixButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.sixButton addTarget:self action:@selector(phoneClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.sixButton];
    [self.sixButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(twoButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 + 15));
        make.height.equalTo(self.mas_height);
    }];
    
    self.fourButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.fourButton setTitle:title forState:UIControlStateNormal];
    self.fourButton.backgroundColor = RGB_COLOR(237,34,59);
    [self.fourButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.fourButton.titleLabel.font = [UIFont systemFontOfSize:14];
    self.fourButton.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.fourButton addTarget:self action:@selector(employClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.fourButton];
    [self.fourButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.threeButton.mas_right);
        make.top.equalTo(self.mas_top);
        make.width.equalTo(@(SCREEN_WIDTH * 0.25 + 15));
        make.height.equalTo(self.mas_height);
    }];
}

-(void)payAttentionClicked
{
    if (_payAttentionClick) {
        _payAttentionClick();
    }
}

-(void)onlineClicked
{
    if (_onlineClick) {
        _onlineClick();
    }
}

-(void)phoneClicked
{
    if (_phoneClick) {
        _phoneClick();
    }
}

-(void)employClicked
{
    if (_employClick) {
        _employClick();
    }
}

-(void)orderClicked
{
    if (_orderClick) {
        _orderClick();
    }
}

-(void)fiveClicked{
    if (_fiveClick) {
        _fiveClick();
    }
}

-(void)sixClicked{
    if (_sixClick) {
        _sixClick();
    }
}
@end
